package com.anivia.common.core.exception;

import com.anivia.common.core.enums.BaseEnum;
import lombok.Getter;

/**
 * 业务中统一抛出异常
 *
 * @author wangj
 */
@Getter
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = -3008701086164361883L;

    private Integer code;
    private String description;
    private Object[] params;

    public BusinessException(String description) {
        super(description);
        this.description = description;
    }

    public BusinessException(BaseEnum baseEnum) {
        super(baseEnum.getDesc());
        this.code = baseEnum.getCode();
        this.description = baseEnum.getDesc();
    }

    public BusinessException(int code, String description) {
        super(description);
        this.code = code;
        this.description = description;
    }

    public BusinessException(int code, String description, Object... params) {
        super(description);
        this.code = code;
        this.description = description;
        this.params = params;
    }

    public BusinessException(BaseEnum handler, String description, Object... params) {
        super(description);
        this.code = handler.getCode();
        this.description = description;
        this.params = params;
    }

    public BusinessException() {
        super();
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return description;
    }

}
